<template>
  <el-row>
    <el-col :span="18">
      <h2
        class="header-title"
        v-text="headerTitle"
      />
    </el-col>
    <el-col :span="6">
      <el-dropdown class="user-setting">
        <span class="el-dropdown-link">
          <i class="fa fa-user" />
          <span
            v-text="userName"
            class="user-name"
          />
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item class="item">
            <span> <i class="fa fa-sign-out fa-unlock-alt" /> 修改密码</span>
          </el-dropdown-item>
          <el-dropdown-item class="item">
            <span @click="logout">
              <i class="fa fa-sign-out fa-nav-icon" /> 退出登录</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-col>
  </el-row>
</template>

<script>
export default {
  name: "AdminHead",
  data() {
    return {
      headerTitle: this.$com.Other._title.headerTitle,
      userName: this.$com.Other.token.personName
    };
  },
  created() {
    // console.log("this.$com.Other.token :", this.$com.Other.token);
  },
  methods: {
    logout() {
      sessionStorage.clear();
      this.$router.replace("/login");
      // window.history.go(0) // 退出后刷新浏览器清理js缓存问题
    }
  }
};
</script>

<style lang="scss">
.header-title {
  margin: 20px;
}
.user-setting {
  float: right;
  margin: 22px 5px;
  cursor: pointer;
}
.user-name {
  margin-left: 5px;
  font-weight: 600;
}
</style>
